<?php

/**
 * @Author: suyuan
 * @Email: 819067126@qq.com
 * @Date: 2020/09/16 13:15
 */


     $dsn = "mysql:dbname=study;host:localhost";
     $user = "root";
     $password = "123456";
    
       


try {
    $db = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

$sql = "SELECT * FROM devices";
$res = $db->query($sql);
$res = $res->fetchAll(PDO::FETCH_ASSOC);
print_r($res);
foreach ($db->query($sql) as $row) {
    print_r($row);
    echo "1";
}
